package com.cx.service.impl;

import com.cx.mapper.BodyMapper;
import com.cx.pojo.Body;
import com.cx.service.BodyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BodyServiceImpl implements BodyService {

    @Autowired
    BodyMapper bodyMapper;

    @Override
    public int insert(Body body) {
        return bodyMapper.insert(body);
    }

    @Override
    public int updateByPrimaryKey(Body body) {
        return bodyMapper.updateByPrimaryKey(body);
    }

    @Override
    public int deleteByPrimaryKey(Integer bodyId) {
        return bodyMapper.deleteByPrimaryKey(bodyId);
    }

    @Override
    public Body selectByPrimaryKey(Integer bodyId) {
        return bodyMapper.selectByPrimaryKey(bodyId);
    }

    //分页
    public PageInfo<Body> selectAllBody(Body body) {
        PageHelper.startPage(body.getPageNum(), body.getPageSize());
        List<Body> bodyList = bodyMapper.selectAllBody(body);
        return new PageInfo<>(bodyList);
    }
}
